package com.jade.shoesmallinterface.mapper;

import com.jade.shoesmallinterface.entity.UserAddress;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserAddressMapper {
    // 根据用户ID查询用户地址信息
    @Select("SELECT * FROM user_address WHERE user_id = #{userId}")
    List<UserAddress> selectAddressesByUserId(Integer userId);

    // 插入新地址
    @Insert("INSERT INTO user_address (user_id, addressType, username, userPhone, addressDetail,create_time,update_time) " +
            "VALUES (#{userId}, #{addressType}, #{username}, #{userPhone}, #{addressDetail},NOW(),NOW())")
    int insertUserAddress(UserAddress userAddress);
}